package com.antler.smt.portal.controller;

import com.antler.smt.enums.ResultCodeEnum;
import com.antler.smt.portal.annotation.OperateCut;
import com.antler.smt.response.base.Result;
import com.antler.smt.service.portal.PurchaserCashCouponService;
import com.antler.smt.utils.LogUtil;
import com.antler.smt.validate.DataValidator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 采购商获取现金礼券控制
 *
 * @author zhangyi
 * @date 2018/5/8 10:05
 */
@RestController
@RequestMapping("/cashCoupon")
@Api(description = "采购商获取现金礼券控制")
public class PurchaserCashCouponController extends BaseController{
    /**
     * 日志
     */
    private static Logger log = LogUtil.get();

    @Resource
    private PurchaserCashCouponService purchaserCashCouponService;

    /**
     * 获取当前用户的采购卷列表
     *
     * @return Result实体
     */
    @GetMapping("/getCashCouponList")
    @ApiOperation(value = "获取当前用户的采购卷列表", httpMethod = "GET")
    public Result getCashCouponList() {
        Result result = null;
            result = purchaserCashCouponService.getCashCouponList(currentMember.getId());
        return result;
    }

    /**
     * 使用后的代金卷
     *
     * @return Result实体
     */
    @GetMapping("/abolishCashCoupon")
    @ApiOperation(value = "使用代金卷", httpMethod = "GET")
    @OperateCut(operationContent = "使用代金卷")
    public Result<ResultCodeEnum> abolishCashCoupon(@RequestParam(value = "cashId") Long cashId) {

        DataValidator.isBlank(String.valueOf(cashId),"代金券id不能为空！");

        Result result = null;
            result = purchaserCashCouponService.abolishCashCoupon(cashId);
        return result;
    }

    /**
     * 获取该采购商所有有效的代金券
     *
     * @return Result实体
     */
    @GetMapping("/getEffectiveCashCouponList")
    @ApiOperation(value = "获取该采购商所有有效的代金券", httpMethod = "GET")
    @OperateCut(operationContent = "查看代金券")
    public Result getEffectiveCashCouponList() {

        Result result = null;
            result = purchaserCashCouponService.getEffectiveCashCouponList(currentMember.getId());
        return result;
    }
    /**
     * 获取该采购商所有无效的代金券
     *
     * @return Result实体
     */
    @GetMapping("/getLoseEfficacyCashCouponList")
    @ApiOperation(value = "获取该采购商所有无效的代金券", httpMethod = "GET")
    @OperateCut(operationContent = "查看无效代金券")
    public Result getLoseEfficacyCashCouponList() {

        Result result = null;
            result = purchaserCashCouponService.getLoseEfficacyCashCouponList(currentMember.getId());
        return result;
    }
}
